using UnityEngine;
using System.Collections;

public class LoadLevel : MonoBehaviour 
{
	public int levelNumber = 1;
	public static string TEST = "Hello World!";
	
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		
	}
	
	void OnTriggerEnter(Collider collider)
	{
		if(collider.gameObject.tag=="Player1" || collider.gameObject.tag=="Player2")
		{	
			
			TEST = "value has changed";
			PlayerData.jumpForce = collider.gameObject.GetComponent<Movement>().jumpForce;
			PlayerData.holdJumpForce = collider.gameObject.GetComponent<Movement>().holdJumpForce;
			PlayerData.notHoldJumpForce = collider.gameObject.GetComponent<Movement>().notHoldJumpForce;
			PlayerData.moveSpeed = collider.gameObject.GetComponent<Movement>().moveSpeed;
//			if(collider.gameObject.GetComponent<Movement>().doubleJumpEnabled !=null)
//			{
//				Debug.Log("Double jump not null!");
//				Debug.Log (collider.gameObject.GetComponent<Movement>().doubleJumpEnabled);
				PlayerData.doubleJumpEnabled = collider.gameObject.GetComponent<Movement>().doubleJumpEnabled;
//			}
			PlayerData.highScore+=PlayerData.levelScore;
			PlayerData.scoreMultiplier = 1;
			 
			Application.LoadLevel(levelNumber);
			//Debug.Log (TEST);
			
			if(levelNumber==9)
			{
				if(PlayerData.highScore>PlayerData.highestScore)
				{
					PlayerData.highestScore = PlayerData.highScore;
				}
			}
		}
	}
}
